package com.neo.impatient.C03_array.C03_07_Arrays

object ArraysTest {
  def main(args: Array[String]): Unit = {

    println("通过语法直接得到二维数组")
    val matrix = Array.ofDim[Double](3, 4)



    matrix(2)(3) = 4
    println(matrix(2)(3))

    println("通过数组的数组可以构造2维")
    val triangle = new Array[Array[Int]](10)
    for(i <- triangle.indices){
      triangle(i) = new Array[Int](i + 5)
    }

    triangle(1)(2) = 5
    println(triangle(1)(2))


    println("通过数组的数组的数组可以构造N为矩阵")
    val triangle3 = new Array[Array[Array[Int]]](10)
    for(i <- triangle3.indices){
      triangle3(i) = new Array[Array[Int]](10)
      for( j <- triangle3(i).indices){
        triangle3(i)(j) = new Array[Int](i + 10)
      }
    }

    triangle3(1)(2)(9) = 3
    println(triangle3(1)(2)(9))


  }
}
